home *** CD-ROM | disk | FTP | other *** search
/ Into That Dark Night / Into That Dark Night.iso / pc / YadVashem / Database / WorkDir / MERGETX.PL < prev    next >
Encoding:
Perl Script  |  1998-04-24  |  1022 b   |  36 lines

  1. #!/usr/local/bin/perl
  2. #
  3. # merge the Image text files.
  4. #
  5. # Eli - 4/24/98
  6. #
  7. # Copyrights @ Possible Worlds Ltd. 1998
  8. #
  9.  
  10.    use Cwd;
  11.    use English;
  12.    
  13.    $mergeName = "imgTxt.txt";
  14.    $currentDir = cwd;
  15.    open (OUTFILE, ">$mergeName");
  16.    opendir(CURDIR, $currentDir)  or die "can't open $dirname\n";
  17.    while ($curFile = readdir(CURDIR)) {
  18.       if ($curFile =~ /TMPIM\d.TXT/i) {
  19.          print "--------- $curFile-----------\n";
  20.          open (FILEIN, "<$curFile") or die "can't open file\n";
  21.          while   (<FILEIN>) {
  22.            $current_line = $_;
  23.            ($itemNum, $picText) = $current_line =~ /^(\d+),(\"[^\"]*\")/;
  24.            if ($itemNum && $picText) {
  25.               $picText =~ s/^\"(.*)\"$/\1/;
  26.               $picItem{$itemNum} = $picText;
  27.            } # if
  28.          } # while
  29.          close (FILEIN);
  30.       } # if the file is one that need processing
  31.    } # while
  32.    foreach $itemNum (sort {$a <=> $b} (keys (%picItem))) {
  33.       print OUTFILE "$itemNum|$picItem{$itemNum}\n";
  34.    }
  35.    close (OUTFILE);
  36.